CREATE TABLE [dbo].[TASALD_EXTE]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_CNTB_EMPR] [dbo].[TD_IN_001_CONT] NOT NULL,
[CO_PLAN_EXTE] [dbo].[TD_VC_003] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TASALD_EX__NU_AN__1B0907CE] DEFAULT (datepart(year,getdate())),
[NU_MESE] [dbo].[TD_IN_002_MESE] NOT NULL,
[CO_CNTA_EXTE] [dbo].[TD_VC_020] NOT NULL,
[IM_CARG_MESE] [dbo].[TD_NU_016_004] NULL CONSTRAINT [DF__TASALD_EX__IM_CA__1DE57479] DEFAULT ((0)),
[IM_ABON_MESE] [dbo].[TD_NU_016_004] NULL CONSTRAINT [DF__TASALD_EX__IM_AB__1FCDBCEB] DEFAULT ((0)),
[IM_CARG_ORIG] [dbo].[TD_NU_016_004] NULL CONSTRAINT [DF__TASALD_EX__IM_CA__21B6055D] DEFAULT ((0)),
[IM_ABON_ORIG] [dbo].[TD_NU_016_004] NULL CONSTRAINT [DF__TASALD_EX__IM_AB__239E4DCF] DEFAULT ((0)),
[PR_DATO] [dbo].[TD_VC_020] NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TASALD_EX__FE_US__25869641] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TASALD_EX__FE_US__267ABA7A] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [CK__TASALD_EX__IM_AB__20C1E124] CHECK (([IM_ABON_MESE]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [CK__TASALD_EX__IM_AB__24927208] CHECK (([IM_ABON_ORIG]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [CK__TASALD_EX__IM_CA__1ED998B2] CHECK (([IM_CARG_MESE]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [CK__TASALD_EX__IM_CA__22AA2996] CHECK (([IM_CARG_ORIG]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [CK__TASALD_EX__NU_AN__1BFD2C07] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [CK__TASALD_EX__NU_CN__1A14E395] CHECK (([NU_CNTB_EMPR]>=(1) AND [NU_CNTB_EMPR]<=(99)))
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [CK__TASALD_EX__NU_ME__1CF15040] CHECK (([NU_MESE]>=(0) AND [NU_MESE]<=(13)))
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [XPKTASALD_EXTE] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_CNTB_EMPR], [CO_PLAN_EXTE], [NU_ANNO], [NU_MESE], [CO_CNTA_EXTE]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [ITASALD_EXTE_01] ON [dbo].[TASALD_EXTE] ([NU_CNTB_EMPR], [NU_MESE]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TASALD_EXTE] ADD CONSTRAINT [FK1_TMPLAN_EXTE_A_TASALD_EXTE] FOREIGN KEY ([CO_EMPR], [CO_PLAN_EXTE], [CO_CNTA_EXTE]) REFERENCES [dbo].[TMPLAN_EXTE] ([CO_EMPR], [CO_PLAN_EXTE], [CO_CNTA_EXTE])
GO
